﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cecbData;

namespace cecbClasses.Data_Adapters.Excel
{
    public class CreateExcell
    {
         
        public CreateExcell() {
            cecbContext = new DSSEntities();
        }

        DSSEntities cecbContext;



        public List<Impacts> getImpacts(string project)
        {
            List<Impacts> list = new List<Impacts>();
            IQueryable<Impacts> quary = (from p in cecbContext.Impacts
                                         join b in cecbContext.ProjectImpacts
                                         on p.impt_reference
                                         equals b.impt_reference
                                         where
                                         b.proj_reference == project

                                         select p);
            list = quary.ToList();


            // (from a in context.Accounts
            // join c in context.Clients on a.UserID equals c.UserID
            // where c.ClientID == yourDescriptionObject.ClientID
            // select a.Balance)
            //.SingleOrDefault();

            //(from c in ce.Campaign.Include("Test")
            // join t in ce.Tests.Include("TestAnswer").Include("User") on c.Test.ID equals t.ID
            // where c.ID == campaignID
            // select c).FirstOrDefault();




            list = quary.ToList();
            return list;
        }
        public List<Activities> getActivity(string project)
        {
            //List<string > list = new List<string >();
            //IQueryable<string > quary = from p in cecbContext.ProjectImpacts
            //                           where
            //                           p.proj_reference == "hp"
            //                           select new
            //                           {
            //                               p.Impacts.Impt_name
            //                           }
            //list = quary.ToList();


            //return list;
            List<Activities> list = new List<Activities>();
            IQueryable<Activities> quary = (from p in cecbContext.Activities
                                            join b in cecbContext.ProjectActivities
                                            on p.actv_reference
                                            equals b.actv_reference
                                            where
                                            b.proj_reference == project

                                            select p);
            list = quary.ToList();

            List<string> impacts = new List<string>();
            return list;



        }
        public List<Components> getComponent(string project, string comp_name)
        {
            List<Components> complist = new List<Components>();
            IQueryable<Components> quary = (from p in cecbContext.Components
                                            join b in cecbContext.Impacts on p.cmpt_reference equals b.impt_component
                                            join c in cecbContext.ProjectImpacts on b.impt_reference equals c.impt_reference
                                            where
                                            c.proj_reference == project &&
                                            p.cmpt_name == comp_name


                                            select p);
            complist = quary.ToList();

            return complist;
        }


        public List<string> getComponentMainCat(string project)
        {
            List<string> complist = new List<string>();
            IQueryable<string> quary = (from p in cecbContext.Components
                                        join b in cecbContext.Impacts on p.cmpt_reference equals b.impt_component
                                        join c in cecbContext.ProjectImpacts on b.impt_reference equals c.impt_reference
                                        where
                                        c.proj_reference == project

                                        select p.cmpt_mainCat).Distinct();
            complist = quary.ToList();

            return complist;

        }

    }
}